<?php

/**
 * Level form.
 *
 * @package    elearning
 * @subpackage form
 * @author     Your name here
 */
class LevelForm extends BaseLevelForm
{
  public function configure()
  {

	unset( $this['create_at'],  $this['update_at'] );
	$this->setDefaults( array('create_at' => time(), 'update_at' => time() ) );
	
	//$this->embedI18n(array('en', 'vi'));
	//$this->widgetSchema->setLabel('en', 'English');
	//$this->widgetSchema->setLabel('vi', 'Vietnamese');
	$level = $this->getObject();
	if( $level->getLevelStatus() == 0 )
		$level->setLevelStatus(NULL);
	$this->widgetSchema['level_status'] = new sfWidgetFormInputCheckbox(array("value_attribute_value" => 1),array('value' => 1));
	$this->validatorSchema['level_status'] =  new sfValidatorInteger( array('required' => false ));
	$this->widgetSchema->setNameFormat('level[%s]');
	
	$this->widgetSchema->setLabels(  
		 array(  
			 'course_id'      => 'Course Name', 
			 'level_status'      => 'Active', 
			 'teach_sessions_per_week'      => 'Teach Sessions/Week',  
			 'prac_sessions_per_week'      => 'Practice Sessions/Week',
			 'total_sessions'      => 'Total Sessions',
			 'level_price'     => 'Level Price'  
		 )  
	 );  
	$lang_current = sfContext::getInstance()->getUser()->getCulture();
	$this->languages = array($lang_current => $lang_current);
	$langs = array_keys($this->languages);
	$this->embedI18n($langs);
	foreach($this->languages as $lang => $label)
	{
	  $this->widgetSchema[$lang]->setLabel($label);
	}
	//code de cho hien thi * o cac truong require cung add them 2 dong o backend.css
	$decorator = new sidFormFormatter($this->widgetSchema, $this->validatorSchema);
    $this->widgetSchema->addFormFormatter('custom', $decorator);
    $this->widgetSchema->setFormFormatterName('custom');
	
  }
 }